// main.go
package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	// 创建一个默认的 Gin 路由引擎
	r := gin.Default()

	// 定义一个简单的 GET 路由
	r.GET("/api", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": `
<template>
<div>
<h1>Hello from Dynamic Component!</h1>
<div class="title">
<p>This is a dynamic component rendered from a string.</p>
</div>
<el-table :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>
<el-button type="danger">Default</el-button>
</div>
</template>
<script lang="js" setup>
import {compile, createApp, defineAsyncComponent, onMounted, ref} from 'vue';
const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
onMounted(() => {
 console.log('Dynamic component created');
});
</script>
<style  scoped>
.title{color:red}
</style>`,
		})
	})

	// 启动服务器，监听在 8080 端口
	if err := r.Run(":808"); err != nil {
		panic(err)
	}
}
